﻿using System;
using System.Linq.Expressions;
using CloudShot.Editor.CanvasFigures;

namespace CloudShot.Utils.Tweens
{
  class IntAnimationAdapter<T> : AnimationAdapter where T : IBoundingBoxFigure
  {
    public IntAnimationAdapter(T target, Expression<Func<T, int>> expression, int to)
      : base(target, expression.GetPropertyInfo(), 0, to)
    {
      Begin = (int)PropertyInfo.GetValue(target);
    }

    public override void SetValue(float value)
    {
      PropertyInfo.SetValue(Target, (int)Math.Round(value), null);
    }
  }
}
